<?php

namespace App\Http\Requests\Api;

use Illuminate\Foundation\Http\FormRequest;

class DealRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'price' => 'required|numeric',
            'num' => 'required|numeric|min:1',
            'total_price' => 'required|numeric',
            'security' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'price.required' => '请输入价格',
            'price.numeric' => '价格必须为数字',
            'num.required' => '请输入数量',
            'num.numeric' => '数量必须为数字',
            'num.num' => '至少卖出1个',
            'total_price.required' => '请输入总金额',
            'total_price.numeric' => '总金额必须为数字',
            'security.required' => '请输入交易密码',
        ];
    }

}
